Expand description
§SPMC
A single producer, multiple consumers. Commonly used to implement work-stealing.
§Example
let (mut tx, rx) = spmc::channel();
let mut handles = Vec::new();
for n in 0..5 {
let rx = rx.clone();
handles.push(thread::spawn(move || {
let msg = rx.recv().unwrap();
println!("worker {} recvd: {}", n, msg);
}));
}
for i in 0..5 {
tx.send(i * 2).unwrap();
}
for handle in handles {
handle.join().unwrap();
}
Structs§
- The receiving side of a SPMC channel.
- An error returned from the
Sender::send
orSyncSender::send
function on channels. - The Sending side of a SPMC channel.
Enums§
- This enumeration is the list of the possible reasons that
try_recv
could not return data when called. This can occur with both achannel
and async_channel
.
Functions§
- Create a new SPMC channel.